From 385e2deb9707dd5316b8a78e575cfa876cf36758 Mon Sep 17 00:00:00 2001 From: "robertlipe@gmail.com" Date: Wed, 1 Jan 2014 05:02:52 +0000 Subject: [PATCH] Fixes for tpo, an1, gpsutil, igc. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4693 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/an1.cc | 4 ++-- gpsbabel/gpsutil.cc | 1 + gpsbabel/igc.cc | 18 +++++++++--------- gpsbabel/tpo.cc | 21 +++++++++------------ 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/gpsbabel/an1.cc b/gpsbabel/an1.cc index 2e148fa8f..9b1ab678b 100644 --- a/gpsbabel/an1.cc +++ b/gpsbabel/an1.cc @@ -707,8 +707,8 @@ static void Read_AN1_Waypoints(gbfile* f) } wpt_tmp->longitude = -DecodeOrd(rec->lon); wpt_tmp->latitude = DecodeOrd(rec->lat); - wpt_tmp->notes = xstrdup(rec->comment); - wpt_tmp->description = xstrdup(rec->name); + wpt_tmp->notes = rec->comment; + wpt_tmp->description = rec->name; if (rec->url) { wpt_tmp->AddUrlLink(rec->url); #if NEW_STRINGS diff --git a/gpsbabel/gpsutil.cc b/gpsbabel/gpsutil.cc index ea60883b0..920426660 100644 --- a/gpsbabel/gpsutil.cc +++ b/gpsbabel/gpsutil.cc @@ -113,6 +113,7 @@ data_read(void) wpt_tmp = waypt_new(); wpt_tmp->altitude = alt; wpt_tmp->shortname = sn; + xfree(sn); wpt_tmp->description = desc; wpt_tmp->SetCreationTime(now); diff --git a/gpsbabel/igc.cc b/gpsbabel/igc.cc index b0f2409d9..6c1f3a541 100644 --- a/gpsbabel/igc.cc +++ b/gpsbabel/igc.cc @@ -184,9 +184,9 @@ static void igc_task_rec(const char* rec) // Create a route to store the task data in. rte_head = route_head_alloc(); - rte_head->rte_name = xstrdup(task_num); + rte_head->rte_name = task_num; sprintf(tmp_str, DATEMAGIC "%s: %s", flight_date, task_desc); - rte_head->rte_desc = xstrdup(tmp_str); + rte_head->rte_desc = tmp_str; route_add_head(rte_head); state++; return; @@ -207,7 +207,7 @@ static void igc_task_rec(const char* rec) (lon_deg + (lon_min * 1000 + lon_frac) / 1000.0 / 60); wpt->SetCreationTime(creation); - wpt->description = xstrdup(tmp_str); + wpt->description = tmp_str; // Name the waypoint according to the order of the task record switch (state) { @@ -249,7 +249,7 @@ static void igc_task_rec(const char* rec) waypt_free(wpt); return; } - wpt->shortname = xstrdup(short_name); + wpt->shortname = short_name; route_add_wpt(rte_head, wpt); } @@ -331,15 +331,15 @@ static void data_read(void) // Create a track for pressure altitude waypoints if (!pres_head) { pres_head = route_head_alloc(); - pres_head->rte_name = xstrdup(PRESTRKNAME); - pres_head->rte_desc = xstrdup(trk_desc); + pres_head->rte_name = PRESTRKNAME; + pres_head->rte_desc = trk_desc; track_add_head(pres_head); } // Create a second track for GNSS altitude waypoints if (!gnss_head) { gnss_head = route_head_alloc(); - gnss_head->rte_name = xstrdup(GNSSTRKNAME); - gnss_head->rte_desc = xstrdup(trk_desc); + gnss_head->rte_name = GNSSTRKNAME; + gnss_head->rte_desc = trk_desc; track_add_head(gnss_head); } // Create a waypoint from the fix record data @@ -630,7 +630,7 @@ static void wr_header(void) // is a c string that's used for totally too many things. Just let it // leak for now. 2013-12-31 robertl if (NULL != (wpt = find_waypt_by_name("PILOT")) && !wpt->description.isEmpty()) { - str = xstrdup(CSTRc(wpt->description)); + str = CSTRc(wpt->description); #else if (NULL != (wpt = find_waypt_by_name("PILOT")) && wpt->description) { str = CSTRc(wpt->description); diff --git a/gpsbabel/tpo.cc b/gpsbabel/tpo.cc index 36ef3657a..2b3828001 100644 --- a/gpsbabel/tpo.cc +++ b/gpsbabel/tpo.cc @@ -281,7 +281,7 @@ void tpo_read_2_x(void) /* generate a generic track name */ sprintf(buff, "Track %d", i+1); - track_temp->rte_name = xstrdup(buff); + track_temp->rte_name = buff; /* zoom level 1-5 visibility flags */ gbfread(&buff[0], 1, 10, tpo_file_in); @@ -656,6 +656,7 @@ void tpo_process_tracks(void) xasprintf(&track_name, "TRK %d", ii+1); } track_temp->rte_name = track_name; + xfree(track_name); // RGB line_color expressed for html=rrggbb and kml=bbggrr - not assigned before 2012 sprintf(rgb,"%02x%02x%02x",styles[track_style].color[0],styles[track_style].color[1],styles[track_style].color[2]); @@ -884,6 +885,7 @@ void tpo_process_waypoints(void) // Assign the waypoint name waypoint_temp->shortname = waypoint_name; + xfree(waypoint_name); // Grab the altitude in meters altitude = gbfgetint32(tpo_file_in); @@ -905,9 +907,7 @@ void tpo_process_waypoints(void) gbfread(comment, 1, name_length, tpo_file_in); comment[name_length] = '\0'; // Terminator waypoint_temp->description = comment; -//printf("\tComment: %s\n", waypoint_name); - } else { -// waypoint_temp->description = NULL; + xfree(comment); } // waypoint_temp->notes = NULL; @@ -1110,7 +1110,6 @@ void tpo_process_symbols(void) for (ii = 0; ii < waypoint_count; ii++) { int lat; int lon; - char* waypoint_name; waypoint* waypoint_temp; @@ -1127,9 +1126,7 @@ void tpo_process_symbols(void) waypoint_temp = tpo_convert_ll(lat, lon); // Assign a generic waypoint name - xasprintf(&waypoint_name, "SYM %d", ii+1); -//printf("Waypoint Name: %s\n", waypoint_name); - waypoint_temp->shortname = waypoint_name; + waypoint_temp->shortname = QString().sprintf("SYM %d", ii+1); // waypoint_temp->description = NULL; // waypoint_temp->notes = NULL; @@ -1175,7 +1172,6 @@ void tpo_process_text_labels(void) int lat; int lon; unsigned int name_length; - char* waypoint_name; waypoint* waypoint_temp; @@ -1192,9 +1188,7 @@ void tpo_process_text_labels(void) waypoint_temp = tpo_convert_ll(lat, lon); // Assign a generic waypoint name - xasprintf(&waypoint_name, "TXT %d", ii+1); -//printf("Waypoint Name: %s\t\t", waypoint_name); - waypoint_temp->shortname = waypoint_name; + waypoint_temp->shortname = QString().sprintf("TXT %d", ii+1); for (jj = 0; jj < 16; jj++) { //UNKNOWN DATA LENGTH @@ -1212,6 +1206,7 @@ void tpo_process_text_labels(void) gbfread(comment, 1, name_length, tpo_file_in); comment[name_length] = '\0'; // Terminator waypoint_temp->description = comment; + xfree(comment); //printf("Comment: %s\n", comment); } else { // waypoint_temp->description = NULL; @@ -1290,6 +1285,8 @@ void tpo_process_routes(void) xasprintf(&route_name, "RTE %d", ii+1); } route_temp->rte_name = route_name; + xfree(route_name); + //printf("Route Name: %s\n", route_name); //UNKNOWN DATA LENGTH -- 2.30.2